import os

Import('env')
with open(env['PROJECT_TOOL_S']) as f:
    exec(f.read())

# env.Append(CXXFLAGS=['-O3', '-fopenmp', '-std=c++17'])
SRCS = append_srcs_dir(ADir('src'))
INCLUDE = [ADir('include'), ADir('.')]
PRIVATE_INCLUDE = []
REQUIREMENTS = ['pthread', 'utilities', 'ax_msp', 'eventpp', 'StackFlow', 'single_header_libs']
STATIC_LIB = []
DYNAMIC_LIB = []
DEFINITIONS = []
DEFINITIONS_PRIVATE = []
LDFLAGS = []
LINK_SEARCH_PATH = []
STATIC_FILES = []

DEFINITIONS += ['-O3', '-fopenmp', '-std=c++17']
LDFLAGS+=['-Wl,-rpath=/opt/m5stack/lib', '-Wl,-rpath=/usr/local/m5stack/lib', '-Wl,-rpath=/usr/local/m5stack/lib/gcc-10.3', '-Wl,-rpath=/opt/lib', '-Wl,-rpath=/opt/usr/lib', '-Wl,-rpath=./']
LINK_SEARCH_PATH += [ADir('../static_lib')]
REQUIREMENTS += ['ax_engine', 'ax_interpreter', 'ax_sys']
REQUIREMENTS += ['onnxruntime', 'samplerate']

INCLUDE += [ADir('../include')]
INCLUDE += [ADir('src/runner'), ADir('../include/onnxruntime/core/session')]
INCLUDE += [ADir('src/runner/opencc/include/opencc')]

LINK_SEARCH_PATH += [ADir('../static_lib/opencc/lib')]
# LDFLAGS += ['-l:libcargs.a', '-l:libonnxruntime.a']
LDFLAGS += ['-l:libopencc.a', '-l:libmarisa.a']

STATIC_FILES += Glob('mode_*.json')

env['COMPONENTS'].append({'target':'llm_whisper',
                          'SRCS':SRCS,
                          'INCLUDE':INCLUDE,
                          'PRIVATE_INCLUDE':PRIVATE_INCLUDE,
                          'REQUIREMENTS':REQUIREMENTS,
                          'STATIC_LIB':STATIC_LIB,
                          'DYNAMIC_LIB':DYNAMIC_LIB,
                          'DEFINITIONS':DEFINITIONS,
                          'DEFINITIONS_PRIVATE':DEFINITIONS_PRIVATE,
                          'LDFLAGS':LDFLAGS,
                          'LINK_SEARCH_PATH':LINK_SEARCH_PATH,
                          'STATIC_FILES':STATIC_FILES,
                          'REGISTER':'project'
                          })
